<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>账户信息</title>
	<script src="/static/mobile/js/mui.min.js"></script>
	<link href="/static/mobile/css/mui.min.css" rel="stylesheet"/>
	<link rel="stylesheet" type="text/css" href="/static/mobile/css/basic.css"/>
	<link rel="stylesheet" type="text/css" href="/static/mobile/css/resiter_daili_3.css"/>
	<script type="text/javascript" src="/static/mobile/js/jquery.js"></script>
	<link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
	<script type="text/javascript" charset="utf-8">
		mui.init();
	</script>
	<style>
		.section2 .sub button {
			width: 100%;
			padding: 5px;
			font-size: 1rem;
			color: #fff;
			background: #E52D2D;
			border-color: #E52D2D;
		}
		.slide_btn {
			float: right;
			width: 80%;
		}
		.slide_btn>div{
			float: left;
			width: 33.3%;
			text-align: center;
		}
		.slide_btn>div select{
			width: 100%;
		}
		.slide_btn>div>div>div input{
			width: 100%;
			float: inherit;
			text-align: center;
		}
	</style>
</head>
<body>
<div class="sectionx">
	<header class="mui-bar mui-bar-nav" >
		<a class="mui-icon mui-icon-left-nav mui-pull-left" href="javascript:history.back(-1)" style="color: #4E4E4E;"></a>
		<h1 class="mui-title">个人信息</h1>
		<!--<a class="mui-icon mui-icon  mui-pull-right right1" href="pay_record.html" style="color: #4E4E4E;font-size: 0.8rem;padding-top: 18px;">转账记录</a>-->
	</header>
</div>
<div class="layui-form">
	<form  method="post">
		<div class="section3">
			<div class="container">
				<p>银行账户信息</p>
			</div>
		</div>
		<div class="section2">

			<ul>
				<li class="lix mui-clearfix">
					<span>开户银行</span>
					<input type="text" placeholder="请输入开户银行" name='bank_name' value='{$user.bank_name}'/>
					<span class="xing">*</span>
				</li>

				<li class="lix mui-clearfix">
					<span>开户姓名</span>
					<input type="text" placeholder="请输入开户姓名" name='username'  value='{$user.username}'/>
					<span class="xing">*</span>
				</li>
				<li class="lix mui-clearfix">
					<span>开户账号</span>
					<input type="text" placeholder="请输入开户银行账号" name='bank_card' value='{$user.bank_card}'/>
					<span class="xing">*</span>
				</li>
				<li class="lix mui-clearfix">
					<span>开户地址</span>
					<input type="text" placeholder="请输入开户地址" name='bank_dizhi' value='{$user.bank_dizhi}'/>
					<span class="xing">*</span>
				</li>
			</ul>
		</div>

		<div class="section3">
			<div class="container">
				<p>密码</p>
			</div>
		</div>
		<div class="section2">
			<ul>
				<li class="lix mui-clearfix">
					<span>一级密码</span>
					<input type="password" placeholder="请输入一级密码" name='password' value='{$user.password}'/>
					<span class="xing">*</span>
				</li>

				<li class="lix mui-clearfix">
					<span>二级密码</span>
					<input type="password" placeholder="请输入二级密码" name='twopassword'  value='{$user.twopassword}'/>
					<span class="xing">*</span>
				</li>
			</ul>
			<!--		<div class="ge"></div>
                    <div class="sub">
                        <button type="button" class="layui-btn" lay-filter="sub" lay-submit>保存</button>
                    </div>-->
		</div>
		<div class="section3">
			<div class="container">
				<p>个人信息</p>
			</div>
		</div>
		<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">
		<div class="section2">
			<ul>
				<li class="lix mui-clearfix">
					<span>姓名</span>
					<input type="text" placeholder="请输入姓名" name='username' value='{$user.username}'/>
					<span class="xing">*</span>
				</li>
			</ul>

			<ul>
				<li class="lix mui-clearfix">
					<span>手机号</span>
					<input type="text" placeholder="请输入手机号" name='mobile' value='{$user.mobile}'/>
					<span class="xing">*</span>
				</li>
			</ul>
			<ul>
				<li class=" mui-clearfix">
					<span>收货地址</span>
					<div class="slide_btn">
						<div class="layui-input-inline">
							<select name="province" ng-model="field.province" lay-filter="province" ng-options="v.id as v.name for v in province" ng-selected="v.id==field.province">
								<option value="">请选择省</option>
							</select>
						</div>
						<div class="layui-input-inline" >
							<select name="city" id="city" ng-model="field.city" lay-filter="city" ng-options="v.id as v.name for v in city" ng-selected="v.id==field.city">
								<option value="">请选择市</option>
							</select>
						</div>
						<div class="layui-input-inline">
							<select name="district" id="district" ng-model="field.district" lay-filter="district" ng-options="v.id as v.name for v in district" ng-selected="v.id==field.district">
								<option value="">请选择县/区</option>
							</select>
						</div>
					</div>
				</li>
				<li class="lix mui-clearfix">
					<span>详情地址</span>
					<input type="text" placeholder="请输入详情地址" name='dizhi' value='{$user.dizhi}'/>
					<span class="xing">*</span>
				</li>
			</ul>
			<ul >
				<label class="layui-form-label" style="width: 120px">支付宝收款码</label>
				<input type="hidden" name="zhifubao" id="zhifubao">
				<div class="layui-input-block">
					<div class="layui-upload" >
						<button type="button" class="layui-btn layui-btn-primary" id="logoBtn" onclick="shijian('1')"><i class="icon icon-upload3"></i>点击上传</button>
						<input type="button" id = "btnHide" class="none" style="display: none">
						<div class="layui-upload-list">
							<img class="layui-upload-img" id="cltLogo" style="width: 80%">
							<p id="demoText"></p>
						</div>
					</div>
				</div>
			</ul>
			<ul >

				<label class="layui-form-label" style="width: 120px">微信收款码</label>
				<input type="hidden" name="wechat" id="wechat">
				<div class="layui-input-block">
					<div class="layui-upload" >
						<button type="button" class="layui-btn layui-btn-primary" id="wechatBtn" onclick="shijian('2')"><i class="icon icon-upload3"></i>点击上传</button>
						<input type="button" id = "btnHide2" class="none" style="display: none">
						<div class="layui-upload-list">
							<img class="layui-upload-img" id="wechatcltLogo" style="width: 80%">
							<p id="wechatdemoText"></p>
						</div>
					</div>
				</div>

			</ul>
			<div class="ge"></div>
			<div class="sub">
				<button type="button" class="layui-btn" lay-filter="sub" lay-submit>保存</button>
			</div>
		</div>
			</div>
	</form>
</div>
</body>
<script type="text/javascript" >
	mui('body').on( 'tap' , 'a' , function(){
		document.location.href=this.href;
	})
</script>

<script src="/static/plugins/layui/layui.js"></script>
<script>
	layui.use(['form', 'layer','upload','element'], function () {
		//	var form = layui.form,$ = layui.jquery;
		var form = layui.form,layer = layui.layer,upload = layui.upload,$ = layui.jquery,element = layui.element;

		var user = {$users|raw};
		$('#cltLogo').attr('src',user.zhifubao);
		$('#wechatcltLogo').attr('src',user.wechat);
		// 登录提交监听
		form.on('submit(sub)', function (data) {
			var loading = layer.load(1, {shade: [0.1, '#fff']});
			$.post("{:url('mybank')}",data.field,function(res){
				layer.close(loading);
				if(res.code > 0){
					layer.msg(res.msg,{time:1000,icon:1},function(){
						location.href = "{:url('index/index')}";
					});
				}else{
					layer.msg(res.msg,{time:1000,icon:2});
					// $('.captcha img').attr('src','{:url("verify")}?id='+Math.random());
				}
			});
		})
		var uploadInst = upload.render({
			elem: '#logoBtn'
			,accept: 'images'
			,field: 'file'
			,url: '{:url("user/UpFiles/upload")}'
			,auto: false
			,bindAction: "#btnHide"
			,before: function(obj){
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result){
					$('#cltLogo').attr('src', result); //图片链接（base64）
				});
			},choose: function(obj) {
				var files = obj.pushFile();
				var index, file, indexArr = [];
				for(index in files) {
					indexArr.push(index);
				};
				var iaLen = indexArr.length;
				file = files[indexArr[iaLen - 1]];
				for(var i = 0; i < iaLen - 1; i++) {
					delete files[indexArr[i]];
				}
				try {
					if(file.size > 200 * 1024) {
						delete files[index];
						photoCompress(file, {
							quality: 0.5,
						}, function(base64Codes) {
							var bl = convertBase64UrlToBlob(base64Codes);
							obj.resetFile(index, bl, file.name);
							$("#btnHide").trigger("click");
						});
					} else {
						$("#btnHide").trigger("click");
					}
				} catch(e) {
					$("#btnHide").trigger("click");
				}
			}
			,done: function(res){
				//上传成功
				if(res.code>0){
					$('#zhifubao').val(res.url);
				}else{
					//如果上传失败
					return layer.msg('上传失败');
				}
			}
			,error: function(){
				//演示失败状态，并实现重传
				var demoText = $('#demoText');
				demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
				demoText.find('.demo-reload').on('click', function(){
					uploadInst.upload();
				});
			}
		});

		var uploadInst = upload.render({
			elem: '#wechatBtn'
			,accept: 'images'
			,field: 'file'
			,url: '{:url("user/UpFiles/upload")}'
			,auto: false
			,bindAction: "#btnHide2"
			,before: function(obj){
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result){
					$('#wechatcltLogo').attr('src', result); //图片链接（base64）
				});
			},choose: function(obj) {
				var files = obj.pushFile();
				var index, file, indexArr = [];
				for(index in files) {
					indexArr.push(index);
				};
				var iaLen = indexArr.length;
				file = files[indexArr[iaLen - 1]];
				for(var i = 0; i < iaLen - 1; i++) {
					delete files[indexArr[i]];
				}
				try {
					if(file.size > 200 * 1024) {
						delete files[index];
						photoCompress(file, {
							quality: 0.5,
						}, function(base64Codes) {
							var bl = convertBase64UrlToBlob(base64Codes);
							obj.resetFile(index, bl, file.name);
							$("#btnHide2").trigger("click");
						});
					} else {
						$("#btnHide2").trigger("click");
					}
				} catch(e) {
					$("#btnHide2").trigger("click");
				}
			}
			,done: function(res){
				//上传成功
				if(res.code>0){
					$('#wechat').val(res.url);
				}else{
					//如果上传失败
					return layer.msg('上传失败');
				}
			}
			,error: function(){
				//演示失败状态，并实现重传
				var wechatdemoText = $('#wechatdemoText');
				wechatdemoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
				wechatdemoText.find('.demo-reload').on('click', function(){
					uploadInst.upload();
				});
			}
		});

	})

	/*1
	 */
	function shijian(type) {
		try {
			var data=window.android.upType();
			if(data==1){
				window.android.upload_image(type);
			}
		}catch(e){

		}
	}
	function jieshou(data,type) {
		if(type==1){
			$('#cltLogo').attr('src',data); //图片链接（base64）
			$('#zhifubao').val(data);
		}else{
			$('#wechatcltLogo').attr('src',data); //图片链接（base64）
			$('#wechat').val(data);
		}
	}
</script>
<script src="/static/common/js/angular.min.js"></script>
<script>
	var m = angular.module('hd',[]);
	m.controller('ctrl',function($scope) {
		$scope.field = {$info|raw};
		$scope.group = {$user_level|raw};
		$scope.province = {$province|raw};
		$scope.city = {$city|raw};
		$scope.district = {$district|raw};
		layui.use(['form', 'layer'], function () {
			var form = layui.form, layer = layui.layer,$= layui.jquery;
			form.on('select(province)', function(data) {
				var pid = data.value;
				var loading = layer.load(1, {shade: [0.1, '#fff']});
				$.get("{:url('getRegion')}?pid=" + pid, function (data) {
					layer.close(loading);
					var html='<option value="">请选择市</option>';
					$.each(data, function (i, value) {
						html += '<option value="number:'+value.id+'">'+value.name+'</option>';
					});
					$('#city').html(html);
					$('#district').html('<option value="">请选择县/区</option>');
					form.render()
				});
			});
			form.on('select(city)', function(data) {
				var pid = data.value;
				var loading = layer.load(1, {shade: [0.1, '#fff']});
				$.get("{:url('getRegion')}?pid=" + pid, function (data) {
					layer.close(loading);
					var html='<option value="">请选择县/区</option>';
					$.each(data, function (i, value) {
						html += '<option value="number:'+value.id+'">'+value.name+'</option>';
					});
					$('#district').html(html);

					form.render()
				});
			});
			form.on('submit(submit)', function (data) {
				// 提交到方法 默认为本身
				var loading = layer.load(1, {shade: [0.1, '#fff']});
				data.field.id = $scope.field.id;
				$.post("", data.field, function (res) {
					layer.close(loading);
					if (res.code > 0) {
						layer.msg(res.msg, {time: 1800, icon: 1}, function () {
							location.href = res.url;
						});
					} else {
						layer.msg(res.msg, {time: 1800, icon: 2});
					}
				});
			})
		});
	});
</script>

</html>